<?php
echo "<pre>";
function upload2()
{
	$files=array();
	foreach($_FILES['up']['name'] as  $id=>$name)
	{
		//创建上传目录
		$dir = 'upload/'.date("y/m");
		is_dir($dir) or mkdir($dir,0755,true);
		// echo $id.'==>'.$name."<br/>";
		if($_FILES['up']['error'][$id] ==0)
		{
			//判断是否是合法上传文件
			if(is_uploaded_file($_FILES['up']['tmp_name'][$id]))
			{ 
				$info = pathinfo($_FILES['up']['name'][$id]);
				$dest = $dir.'/'.mt_rand().time().'.'.$info['extension'];
				if(move_uploaded_file($_FILES['up']['tmp_name'][$id], $dest))
				{
					$files[]=array(
						'name'=>$_FILES['up']['name'][$id],
						'type'=>$_FILES['up']['type'][$id],
						'size'=>$_FILES['up']['size'][$id],
						'time'=>time(),
						'filename'=>$dest
					);	
				}
			} 
		}
	}

	return $files;
} 

